import React from 'react'
import '../css/home.css'
import Event from '../index/Event'


class Home extends React.Component{
    constructor(props){
      super();
      this.state={
        list:[]
      }
  
    }
  
    render(){
      return(
        <div>
          <div className="header">
          <div className="header2">
            <div className="header-text">
            ToDoList
            </div>
            <div>
              <input type="text" ref="input" placeholder="添加todo" className="header-input" onKeyDown={(e)=>{
                if(e.keyCode==13){
                  let input=this.refs.input.value
                  
                  if(input.length>0){

                    var todolist={
                      name:input,
                      fel:false
                    }
                    // console.log(todolist);
                  
                    Event.emit('add',todolist)

                  }else{
                    alert('请输入内容');
                  this.refs.input.value=''
                    return
                  }




                  this.refs.input.value=''



                }

              }


              }/>


            </div>
            

            </div>
          </div>
          
        </div>
      )
    }
  
    
  
  
  
  
  }
  
  export default Home;